/*
 * tcpServer.java
 *
 * Created on January 7, 2006, 5:16 PM
 *
 * To change this template, choose Tools | Options and locate the template under
 * the Source Creation and Management node. Right-click the template and choose
 * Open. You can then make changes to the template in the Source Editor.
 */

/**
 *
 * @author Sujal Bista
 */
import java.net.*;
import java.io.*;

public class tcpServer extends Thread
{
    //output structure
    private showOutput output;

    tcpServer(showOutput output)
    {
        this.output=output;
    }

    public void run()
    {
        ServerSocket server_socket;
	BufferedReader socketInput;
        PrintWriter socketOutput;

        output.printLn("Server Address : " +  globalData.setupInfo.getServerName().toString());
        output.printLn("Port no : " +  globalData.setupInfo.getPortNum());

	try
        {

	    //server_socket = new ServerSocket(globalData.setupInfo.getPortNum(),5,globalData.setupInfo.getServerName());
	    server_socket = new ServerSocket(globalData.setupInfo.getPortNum(), 10);
	    output.printLn("Server waiting for client on port " + server_socket.getLocalPort());

	    // server infinite loop
	    while(true)
            {
		Socket socket = server_socket.accept();
		output.printLn("New connection accepted " + socket.getInetAddress() + ":" + socket.getPort());

                serveClient client=new serveClient(socket,output);
                client.start();
	    }
	}
	catch (IOException e)
        {
	    System.out.println(e);
	}

    }
}




